<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.sinodata.bsm.center.util.spring.SpringContextHolder"%>
<%@page import="com.sinodata.bsm.center.service.resource.ResService"%>
<%@ page import="com.sinodata.bsm.common.vo.*" %>
<%@ page import="com.sinodata.bsm.common.constants.ResConstants" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
ResService service = SpringContextHolder.getBean(ResService.class);
List<Res> list = (List<Res>)request.getAttribute("appList");
Map<Long, Integer[]> events = ( Map<Long, Integer[]>)request.getAttribute("events");
Map<Long, Integer[]> useabalityMap = ( Map<Long, Integer[]>)request.getAttribute("useabalityMap");

Map<Long, String> map = new HashMap<Long,String>();
for(Res res : list){
String str = "<chart  bgColor='#edf9ff' showTickValues='1'  showBorder='0'  lowerLimit='0' fontcolor='000000' upperLimit='100' ";
str += " majorTMColor='FFFFFF' majorTMAlpha='1' majorTMNumber='6' minorTMNumber='0' ";
str += " tickValueStep='1'    tickValueDistance='10'   showTickMarks='1'  showBorder='0' basefontColor='000000' ";
str += " chartTopMargin='5' chartBottomMargin='5' gaugeInnerRadius='0' gaugeOuterRadius='40' fillAngle='50' chartLeftMargin='8' chartRightMargin='15' ";
str += " toolTipBgColor='80A905' > ";
str += "<colorRange>";
str += "<color minValue='0' maxValue='20' code='#ce110f' />";
str += "<color minValue='20' maxValue='40' code='#ff9937' />";
str += "<color minValue='41' maxValue='60' code='#dede03' />";
str += "<color minValue='61' maxValue='80' code='#56a8f4' />";
str += "<color minValue='81' maxValue='100' code='#2cb900' />";
str += "</colorRange>";
str += "<dials>";
str += "<dial value = '"+res.getHealthDegree()+"' rearExtension='10' radius='35' />";
str += "</dials>";
str += "</chart>";
map.put(res.getId(),str);
}

%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<%@ include file="../include/taglib.jsp"%>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/tooltip.jsp"%>
<title>中科金财IT综合监控系统</title>
<link type="text/css" rel="stylesheet" href="/bsm/style/default/bsm/appview.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  <%
			for(Res res : list){
			   String values = map.get(res.getId());
 %>
			var resid = '<%=res.getId()%>';
			var myChart = new FusionCharts("${pageContext.request.contextPath}/resources/charts/AngularGauge.swf","myChartId"+resid, 120, 65, "0", "0");
		myChart.setDataXML("<%=values%>");
		myChart.render("yibiao_"+resid);  

		
	 <%} %>

});
</script>
</head>
<body style="background:#fff url(/bsm/style/default/bsm/appview/max_bg.jpg) repeat-x left top;">
	   <div class=max>
	   		  <h2 class="View">
				  <span class="f_l">应用视图</span>
				     <span class="f_r">
				     <a href="${pageContext.request.contextPath}/appview/app!input.action"></a>
				     	<span style="cursor:pointer;" onclick="javascript:window.location.assign('${pageContext.request.contextPath}/appview/app!input.action');">增加应用监控</span>	
				     </span>		 		  
			 </h2>  
		     <div class="main">
			           <!--网银系统1-->
			           <%
			           	for(Res res : list){
			           	    Integer[] counters = events.get(res.getId().longValue());
			           %>
					   <div class="container">
					          <h3>
							   <span class="h3_left"><a href="/bsm/jsp/appview/viewdetail1.jsp?resid=<%=res.getId() %>" > <%=res.getName()%></a></span>
							 <!--    <span class="h3_right"><a href="${pageContext.request.contextPath}/appview/app!initUpdate.action?id=<%=res.getId() %>"></a></span>		-->				  
							 </h3>
							   <div class="container_main">
							   <!--仪表盘-->
								  <div class="yibiao">
								    <h4>健康状况</h4>
									<div class="yibiao_content" id="yibiao_<%=res.getId()%>"></div>
									<div><span>当前值：</span><span><a href="#">
										<%
										String[] healthArr = ResConstants.HEALTH_DESC;
											out.print(healthArr[res.getHealthStatus()-1]);
										%>
									</a></span></div>
								  </div>
							   <!--@end 仪表盘-->
							   <!--可用性状态-->
								  <div class="kyx">
								     <h4>可用性状态</h4>
								    <div class="kyx_content">
								      <div class="kyx_content_left">
								        <a class="kyx_content_Pellet">
								          <%
								        	Integer[] usedCounter = useabalityMap.get(res.getId());
								        int used =0;
								        int unused =0;
								        String percentStr="";
										int picture=0;
								        if(usedCounter!=null){
								        	 used =usedCounter[0];
								        	 unused =usedCounter[1];
								        	 if(used+unused!=0){
								        		int percent=used*100/(used+unused);
								        		 percentStr=String.valueOf(percent);
								        		 if(percent<=0){
								        		     picture =0;
								        		 }else if(percent<20){
								        		     picture =2;
								        		 }else if(percent<50){
								        		     picture =4;
								        		 }
								        		 else if(percent<60){
								        		     picture =5;
								        		 }
								        		 else if(percent<80){
								        		     picture =6;
								        		 }
								        		 else if(percent<100){
								        		     picture =8;
								        		 }else if(percent==100){
								        		     picture =100;
								        		 }
								        	 }
								        }
								        %>
								        <img src="/bsm/style/default/bsm/appview/Pellet<%=picture %>.png" width="45" height="45"/><span>
								      	<%	
								      		if(percentStr!=""){out.print(percentStr+"%");}
								      	%>
								        </span></a>
								      </div>
								      <div class="kyx_content_right">
									  <a class="kyx_content_top"><img src="/bsm/style/default/bsm/appview/bky.png" width="16" height="16"/><span class="red"><%=unused %></span></a>
									  <a class="kyx_content_bottom"><img src="/bsm/style/default/bsm/appview/ky.png" width="16" height="16"/><span class="green"><%=used %></span></a>									
									  </div>
									 </div>
									
								  </div>
							   <!--@end 可用性状态-->
							   
							   <div class="shijinatongji">
							   	  <h4>故障定位</h4>
							 
	                              <!--图文列表-->
								  <div class="icon">
									 
									<div class="por-div">
										<a href="#" class="xUla"><img src="/bsm/style/default/bsm/appview/jczy.png" width="36" height="36" /></a>
										<a href="/bsm/jsp/appview/viewdetail1.jsp?resid=<%=res.getId() %>">基础资源</a>
										<%
											if(counters[1]>0){
										%>
										<a href="#"  class="Quantity" title="基础资源事件条数"><img src="/bsm/style/default/bsm/appview/Quantity.png" width="21" height="15"/><span><%=counters[1] %></span></a>
										<%
											}
										%>
									</div>
										 
									<div class="por-div">
										<a href="#" class="xUla"><img src="/bsm/style/default/bsm/appview/yyhj.png" width="36" height="36" /></a>
									<a href="/bsm/jsp/appview/viewdetail2.jsp?resid=<%=res.getId() %>">应用环境</a>
										<%
											if(counters[2]>0){
										%>
										<a href="#"  title="应用环境事件条数" class="Quantity"><img src="/bsm/style/default/bsm/appview/Quantity.png" width="21" height="15"/><span><%=counters[2] %></span></a>
										<%
											}
										%>
									</div>
										 
									<div class="por-div">
										<a href="#" class="xUla"><img src="/bsm/style/default/bsm/appview/xtgl.png" width="36" height="36" /></a>
										<a href="/bsm/jsp/appview/viewdetail3.jsp?resid=<%=res.getId() %>">系统关联</a>
										<%
											if(counters[0]>0){
										%>
										<a href="#"  class="Quantity" title="系统关联异常数量"><img src="/bsm/style/default/bsm/appview/Quantity.png" width="21" height="15"/><span><%=counters[0] %></span></a>
										<%
											}
										%>
									</div>
										 
									<div class="por-div">
										<a href="#" class="xUla"><img src="/bsm/style/default/bsm/appview/jkgl.png" width="36" height="36" /></a>
										<a href="/bsm/jsp/appview/viewdetail3.jsp?resid=<%=res.getId() %>">接口关联</a>
										<%
											if(counters[3]>0){
										%>
										<a href="#" title="接口关联事件条数" class="Quantity"><img src="/bsm/style/default/bsm/appview/Quantity.png" width="21" height="15"/><span><%=counters[3] %></span></a>
										<%
											}
										%>
									</div>
							
								  </div>
								  <!--@end 图文列表-->
								  </div>
					           </div>
			           </div>
			          <% } %>
						<!--@end 网银系统1-->
		  </div>    
		  <br class="clear" />
	   </div>
	
	<!--@end 页脚-->
	
</body>
</html>

